import { sys } from "cc";
import { RandomUtils } from "../../../Core/Utils/RandomUtils";
import SdkTool from "../../../Core/Sdk/SdkTool";

export class ModelGame {
    public static rows = 8;
    public static columns = 8;
    public static gridwidth = 90;
    public static gridheight = 90;
    public static readonly pieceValues: string[] = [`cheng`, `hong`, `lan`, `lv`];
    public static get pieceValue(): string {
        return RandomUtils.ins.randomArray(ModelGame.pieceValues);
    }
    public static get coin(): number {
        var score = sys.localStorage.getItem(`coin_score${SdkTool.ins.openid}`);
        return Number(score) || 0;
    }
    public static set coin(value: number) {
        var score = sys.localStorage.getItem(`coin_score${SdkTool.ins.openid}`);
        score = Number(score) || 0;
        sys.localStorage.setItem(`coin_score${SdkTool.ins.openid}`, (score + value) + "");
    }
    public static getlevel(val: string): number {
        var level = sys.localStorage.getItem(`level_${val}${SdkTool.ins.openid}`);
        if (level) {
            return Number(level);
        } else {
            return 0;
        }
    }
    public static setlevel(val: string, level: number) {
        sys.localStorage.setItem(`level_${val}${SdkTool.ins.openid}`, level + "");
    }
}